<template>
  <div>
<!--    搜索头-->
    <div class="searchTitle">
      <el-row :gutter="20">
        <el-col :span="4">
          <el-input
            type="text"
            v-model="userName"
            placeholder="用户名"
            clearable
          ></el-input>
        </el-col>
        <el-col :span="8">
          <el-button @click="searchLog" size="small" type="primary">查询</el-button>
        </el-col>
      </el-row>
    </div>

<!--    表格-->
    <div>
      <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
          prop="id"
          label="操作序列"
          width="180">
        </el-table-column>
        <el-table-column
          prop="userName"
          label="用户名"
          width="180">
        </el-table-column>
        <el-table-column
          prop="message"
          label="操作记录">
        </el-table-column>
        <el-table-column
          prop="createTime"
          label="插入时间">
          <template slot-scope="scope">
            {{ scope.row.createTime | dateFormate}}
          </template>
        </el-table-column>
        <el-table-column
          prop="updateTime"
          label="修改时间">
          <template slot-scope="scope">
            {{ scope.row.updateTime | dateFormate}}
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        :page-sizes="[10,20,30]"
        :page-size="pageSize"
        :current-page="pageNo"
        @current-change="nextPageClick">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {searchLog} from '../api/api'

export default {
  name: 'userLog',
  data() {
    return {
      userName:"",
      tableData:[],
      loginUserName:"",
      total: 1,
      pageSize: 10,
      pageNo: 1,
    }
  },
  created () {
  },
  methods: {
    async searchLog(){
      let param = {
        userName: this.userName,
        pageSize: this.pageSize,
        pageNo: this.pageNo
      }
      var result = await searchLog(param)
      this.tableData = result.detailData.records;
      this.total = result.total;
    },
    async nextPageClick(val){
      let param = {
        userName: this.userName,
        pageSize: this.pageSize,
        pageNo: val
      }
       var result = await searchLog(param);
      this.tableData = result.detailData.records;
    }
  }
}
</script>

<style scoped>

</style>